package com.cuz.hot100;

public class Q55JumpGame {
    public static void main(String[] args) {
//        int[] ints = {2, 3, 1, 1, 4};
        int[] ints = {3, 2, 1, 0, 4};
        System.out.println(canJump1(ints));
    }

    public static boolean canJump1(int[] nums) {
        int maxIndexCanBe = 0;
        for (int i = 0; i < nums.length; i++) {
            if (i <= maxIndexCanBe) {
                maxIndexCanBe = Math.max(maxIndexCanBe, nums[i] + i);
            }
            if (maxIndexCanBe>=nums.length-1){
                return true;
            }
        }
        return false;
    }
}
